package com.woniu.mgr.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.mgr.common.Result;
import com.woniu.mgr.controller.form.ModifyVenueForm;
import com.woniu.mgr.model.Venue;
import com.woniu.mgr.service.VenueService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 场馆表 前端控制器
 * </p>
 *
 * @author Silas
 * @since 2023-02-15
 */
@RestController
@RequestMapping("/venue")
@Slf4j
@Api(tags = "场馆删改查")
public class VenueController {
    @Resource
    private VenueService venueService;

    @GetMapping("/venueGet")
    @ApiOperation("查询")
    public Result venueGet(String condition, Integer current, Integer size) {
        log.info("执行了场馆查询操作 {}{}{}",condition,current,size);
        Page<Venue> list = venueService.query(condition, current, size);
        return Result.success(200, "查询成功",list);
    }
    @PostMapping("/venueDel")
    @ApiOperation("禁用")
    public Result venueDel(Integer id) {
        log.info("执行了场馆禁用操作 {}",id);
        Venue byId = venueService.getById(id);
        byId.setState("不可用");
        venueService.updateById(byId);
        return Result.success(200, "禁用成功", null);
    }

    @PostMapping("/venueStart")
    @ApiOperation("启用")
    public Result venueStart(Integer id){
        log.info("执行了场馆启用操作 {}",id);
        Venue byId = venueService.getById(id);
        byId.setState("可用");
        venueService.updateById(byId);
        return Result.success(200, "启用成功", null);
    }



    @PutMapping("/venueModify")
    @ApiOperation("修改")
    public Result venueModify(ModifyVenueForm modifyVenueForm) {
        log.info("执行了场馆修改操作 {}",modifyVenueForm);
        venueService.modify(modifyVenueForm);
        return Result.success(200, "修改成功", null);
    }


}

